let token = sessionStorage.getItem("token");
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg); //匹配目标参数
    if (r != null) return unescape(r[2]);
    return null; //返回参数值

}
let id = "";
$(function () {
    // const paramsString = window.location.href;
    // const URLSearchParams = new URLSearchParams(paramsString);
    //  let ids = URLSearchParams.get('id');
    //     console.log(ids);
    //接收URL中的参数id
    id = getUrlParam('id');
    $.ajax({
        url:testurl + "motion/degree_info",
        type:"post",
        headers: { "Authorization": "Bearer " + token},
        contentType: "application/json",
        data:JSON.stringify({
            "motion_id":id
        }),
        success:function (data) {

            $("#no").html(data.obj.no);
            $("#realname").html(data.obj.realname);
            $("#organ_post").html(data.obj.organ_post);
            $("#title").html(data.obj.title);
            $("#bldw").html(data.obj.bldw);
        }
    })
});
function submitEv() {
    let tel_num = $("#tel_num").val();
    let letter_num = $("#letter_num").val();
    let face_num = $("#face_num").val();
    let no_contact = $("#no_contact").val();
    let suggest = $("#suggest").val();
    let handle_attitude = $("input[name='RadioButtonList1']:checked").val();
    let handle_result = $("input[name='RadioButtonList2']:checked").val();
    if ((letter_num != "" || face_num != "" || no_contact != "" || tel_num != "") && handle_attitude === "" && handle_result === ""){
        alert("请填写带*必填项！");
        return false;
    }else{
        $.ajax({
            url: testurl + "motion/degree",
            type: "post",
            headers: { "Authorization": "Bearer " + token },
            contentType: "application/json",
            data: JSON.stringify({
                "id": id,//议案id
                "tel_num": tel_num,//电话沟通
                "letter_num": letter_num,//信函沟通
                "face_num": face_num,//面对面沟通
                "no_contact": no_contact,//未联系
                "handle_attitude": handle_attitude,//办理态度 1很满意 2满意 3基本满意 4不满意
                "handle_result": handle_result,//办理结果 1很满意 2满意 3基本满意 4不满意
                "suggest": suggest
            }),
            success: function (data) {
                if (data.success === true) {
                    alert("成功");
                    window.opener.location.reload();
                    self.close();
                } else {
                    alert("失败");
                    window.opener.location.reload();
                    self.close();
                }
            }
        })
    }

}